package com.compass.doctor.ui.mine.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.compass.doctor.R
import com.compass.doctor.databinding.LayoutPatientFollowItemBinding
import com.compass.framework.adapter.BaseBindViewHolder
import com.compass.framework.adapter.BaseRecyclerViewAdapter
import com.compass.framework.glide.setUrlCircle
import com.compass.framework.model.PatientFollow
import com.compass.framework.utils.DateUtils
import com.compass.framework.utils.getDrawableResource

/**
 * Description： 关注患者
 * Date:2024/1/27 10:42
 */
class PatientFollowAdapter : BaseRecyclerViewAdapter<PatientFollow, LayoutPatientFollowItemBinding>() {


    override fun getViewBinding(
        layoutInflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): LayoutPatientFollowItemBinding {
        return LayoutPatientFollowItemBinding.inflate(layoutInflater, parent, false)
    }

    override fun onBindDefViewHolder(
        holder: BaseBindViewHolder<LayoutPatientFollowItemBinding>,
        item: PatientFollow?,
        position: Int
    ) {
        if (item == null) return
        holder.binding.apply {
            tvName.text = item.getUserNam()
//            tvAge.text = "${item.getAge()}岁"
            ivHead.setUrlCircle(item.patientUseravatar)
            ivSex.background= if (item.patientUsersex==1) getDrawableResource(R.mipmap.icon_male) else  getDrawableResource(
                R.mipmap.icon_female)
            followTime.text="关注时间：${DateUtils.conversionTime(item.followTime,DateUtils.FORMAT_TWO)}"
        }
    }
}
